/**
 * 文件名:AuthorServiceImpl.java
 * 包名:com.wx.demo.webc.service.impl
 * 创建时间:2017年2月20日上午10:58:14
 * <p>Copyright ®医界互联 TUS 平台版权所有。</p>
 *
 */

package com.wx.demo.wcd.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wx.demo.wcd.domain.po.AuthorPO;
import com.wx.demo.wcd.domain.qo.AuthorQO;
import com.wx.demo.wcd.infrastructure.dao.AuthorDao;
import com.wx.demo.wcd.service.AuthorService;
import com.yjhl.framework.dao.query.Page;

/**
 * 类名:AuthorServiceImpl <br/>
 * 创建时间: 2017年2月20日 上午10:58:14 <br/>
 * 
 * @author 王笑 Email:wangxiao@yijiehulian.com.
 * @version
 * @since JDK 1.8
 * @see
 */
@Service("authorService")
public class AuthorServiceImpl implements AuthorService {
	private Logger logger = Logger.getLogger(getClass());

	@Autowired
	private AuthorDao authorDao;

	@Override
	public int insert(AuthorPO author) throws Exception {

		logger.debug("insert author content ===>" + author.inputDescription());

		int rows = authorDao.insert(author);

		logger.debug("insert author columns ===> " + rows);

		return rows;
	}

	@Override
	public int insertBatch(List<AuthorPO> la) throws Exception {

		logger.debug("insertBatch List<AuthorPO> lp content ===>"
				+ la.toString());

		int rows = authorDao.insertBatch(la);

		logger.debug("insertBatch columns ===> " + rows);

		return rows;
	}

	@Override
	public int edit(AuthorPO entityPo, AuthorQO entityQo) throws Exception {

		logger.debug("edit entityPo content ===>" + entityPo.inputDescription());
		logger.debug("edit entityQo content ===>" + entityQo.inputDescription());

		int rows = authorDao.updateSelective(entityPo, entityQo);

		logger.debug("edit columns ===> " + rows);

		return rows;
	}

	@Override
	public int delete(String author_id) throws Exception {
		logger.debug("delete author_id content ===>" + author_id);

		int rows = authorDao.deleteByPk(author_id);

		logger.debug("delete columns ===>" + rows);

		return rows;
	}

	@Override
	public int deleteBatch(AuthorQO author) throws Exception {

		logger.debug("deleteBatch AuthorQO content ===>"
				+ author.inputDescription());

		int rows = authorDao.delete(author);

		logger.debug("deleteBatch columns ===>" + rows);

		return rows;
	}

	@Override
	public AuthorPO selectById(String author_id) throws Exception {

		logger.debug("selectById author_id content ===>" + author_id);

		AuthorPO entity = authorDao.getByPk(author_id);

		logger.debug("selectById columns ===>" + entity.inputDescription());

		return entity;
	}

	@Override
	public Page<AuthorPO> selectCondition(AuthorQO author) throws Exception {

		logger.debug("selectCondition AuthorQO content ===>"
				+ author.inputDescription());

		Page<AuthorPO> entity = authorDao.find(author);

		logger.debug("selectCondition columns ===>" + entity.toString());

		return entity;
	}

	@Override
	public Page<AuthorPO> selectAll(AuthorQO author) throws Exception {

		logger.debug("selectCondition AuthorQO content ===>"
				+ author.inputDescription());

		Page<AuthorPO> entity = authorDao.find(author);

		logger.debug("selectCondition columns ===>" + entity.toString());

		return entity;
	}

	@Override
	public int selectCount(AuthorQO author) throws Exception {

		logger.debug("selectCount AuthorQO content ===>"
				+ author.inputDescription());

		int rows = authorDao.count(author);

		logger.debug("selectCount columns ===>" + rows);

		return rows;
	}

	@Override
	public List<AuthorPO> selectCondition1(AuthorQO author) throws Exception {

		logger.debug("selectCondition AuthorQO content ===>"
				+ author.inputDescription());

		List<AuthorPO> entity = authorDao.find(author).getPageList();

		logger.debug("selectCondition columns ===>" + entity.toString());

		return entity;
	}
}
